<template>
  <div id="app">
    <el-card shadow="always" align="center">

      <!--1. 条件查询部分-->
      <el-form :inline="true" :model="user" class="demo-form-inline" align="left" style="margin-left: 40px;">
        <el-form-item>
          <el-input v-model="user.username" placeholder="用户名" size="medium"></el-input>
        </el-form-item>
        <el-form-item >
          <el-input v-model="user.password" placeholder="密码" size="medium"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="success" @click="login" size="medium" plain>登录</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
  import Cookies from 'js-cookie'
  export default {
    data() {
      return {
        user:{}
      }
    },
    created() {

    },
    methods: {
      login(){
        this.axios.post("/user/login",this.user).then(resp => {
            let token = resp.data.token
            Cookies.set("token",token)    // 存放值到cookie中

        })
        this.axios.request(
                {
                  url:"/user/list",
                  method:"get",
                  headers: {"token":Cookies.get("token")},
                  // data:data
              }
        )
      }
    }
  }
</script>
<style>

</style>
